ODFDraw: The class CBaseShape maintains the flagfPromised to tell if a shape is promised or not. Because a shape can be promised for different storage types (linking, clipboard...), fPromised is not just a boolean but an array of bit flags. Whenever a shape’s property is about to be changed the method CBaseShape::CheckPromise is called; if the shape is promised the promise is fulfilled before the shape is modified.
ODFDraw subclasses FW_CPromise (CDrawSelectionPromise ) and implements the FulfillPromise method. In CDrawSelection::Externalize an instance of CDrawSelectionPromise is created and Promise() is called for each promised data type.
CDrawSelectionPromise keeps track of a content object (CDrawPromiseContent) and the FulfillPromise method will be called to fulfill the promise for a specific data type.
Multiple Kinds
ODFDraw: ODFDraw supports two data types for data interchange: its own internal format which is simply a list of shapes, and PICTs. Take a look at the methods CDrawSelectionContent:Externalize and CDrawSelectionPromise::FulfillPromise. This version of ODFDraw doesn't save a document with multiple representations yet.
ODFBitmap: like ODFDraw, ODFBitmap supports both its own internal format (streamed pixmap) and PICTs (only for internalization not externalization). Also, like ODFDraw, ODFBitmap supports multiple kinds only for clipboard and drag&drop operations (see CBitmapContent::Externalize). All the code dealing with multiple kinds is in CBitmapContent.
Cut/Copy/Paste/Clear
ODFBitmap: doesn’t define its own clipboard command class, but cut, copy, paste, and clear work via the selection object, CBitmapSelection. The selection object supplies a reference to the content object (in GetSelectedContent) when requested by ODF for data interchange operations. For a cut or copy, the content object’s Externalize method is called (see CBitmapSelectionContent::Externalize). For a paste, the content object’s Internalize method is called (see CBitmapSelectionContent::Internalize).
ODFContainer, ODFDraw, ODFEmbed, ODFHello, ODFTable: each defines a clipboard command class that is undoable. Note that the code for undoing and redoing clipboard operations is pretty much the same conceptually across all the parts.
ODFForm: defines a clipboard command class that works with edit views (CViewEditCommand).
Drag
ODFBitmap: doesn’t define its own drag command class, but a drag works because a) the frame has FW_MDraggableFrame mixed in, and b) ODFBitmap implements a selection object, CBitmapSelection.
ODFContainer, ODFDraw, ODFEmbed, ODFHello, ODFTable: each defines a drag command class that is undoable. Note that the drag command’s undo code is only called for a drag operation that removed data from the part. So the code for undoing a drag is similar to that for undoing a cut; compare the UndoIt methods in CEmbedEditCommand and CEmbedDragCommand in ODFEmbed.
Drop
ODFBitmap: doesn’t define a drop command class, but a drop works because a) the frame has FW_MDroppableFrame mixed in, and b) ODFBitmap implements a selection object, CBitmapSelection.
ODFContainer, ODFDraw: define undoable drop commands. The drop command has to save the dropped data (in SaveRedoState) so that it can be restored in case of redo. It doesn’t have to save previous content because the dropped data is simply added to the part’s data.
ODFEmbed, ODFHello: the drop command saves the previous content (in SaveUndoState) and restores it on undo. Undoing a drop command is similar to undoing a paste; compare the UndoIt methods in CEmbedEditCommand and CEmbedDropCommand.
ODFTable: doesn’t allow a part to be dropped in a cell that is already occupied. This is enforced by the drop tracker (see CTableDropTracker::ShouldHilite).